import JSEncrypt from 'jsencrypt/bin/jsencrypt.min';

// 新公钥（替换后）
const publicKey = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAos+ls73t+rhSeSMRMqo/
0oB0//OhIbTELgkKvghR/jYqIkd7MTb/wV7brUtYqaNA6t5oEK8EC5BXjAXhEBdm
XYGe42rie8L1Hty3BellxtLpfZ2T2SCXyOKBfbGRa/fgK9U1up+OIAqn5I2TJo2x
mTVuLhSwa0ZeyShqkUQAfPpXl5BWWGtjoctmilKy+tUvKBPcxz4qhJQgCJPHOtxX
m3kBTjmsCC4Jb2h0BTEKv9BrTJNTZKKhFTuXfigoiIFn6ZT1jEQ5CsDzue5xJFeE
D65vBJpA+4eDgz86gatG/kAeX67WYIEAlXXgGiYmhSVzP1IYX6AZJK1uiDepi6v1
0QIDAQAB
-----END PUBLIC KEY-----`;

// 新私钥（替换后）
const privateKey = `-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCiz6Wzve36uFJ5
IxEyqj/SgHT/86EhtMQuCQq+CFH+NioiR3sxNv/BXtutS1ipo0Dq3mgQrwQLkFeM
BeEQF2ZdgZ7jauJ7wvUe3LcF6WXG0ul9nZPZIJfI4oF9sZFr9+Ar1TW6n44gCqfk
jZMmjbGZNW4uFLBrRl7JKGqRRAB8+leXkFZYa2Ohy2aKUrL61S8oE9zHPiqElCAI
k8c63FebeQFOOawILglvaHQFMQq/0GtMk1NkoqEVO5d+KCiIgWfplPWMRDkKwPO5
7nEkV4QPrm8EmkD7h4ODPzqBq0b+QB5frtZggQCVdeAaJiaFJXM/UhhfoBkkrW6I
N6mLq/XRAgMBAAECggEAFhhUBoaaC1KEbsghh1yveKPSPQIVNfvQO+ciPBPo/LTh
FvHYeB9cqiNzcJsvFyZ+ouE4AjueMuuN1gTePE7Qp5P1uitBPUaB+YQ+mmDIXSk2
YsPF0sunja2foS097Qcg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02NtkytifMREsi0PE
3GZp9BDJzAxWMFuRg03DVD0=
-----END PRIVATE KEY-----`;

// 加密函数（使用新公钥）
export function encrypt(txt) {
  const encryptor = new JSEncrypt();
  encryptor.setPublicKey(publicKey); // 设置新公钥
  return encryptor.encrypt(txt); // 对数据进行加密
}

// 解密函数（使用新私钥）
export function decrypt(txt) {
  const encryptor = new JSEncrypt();
  encryptor.setPrivateKey(privateKey); // 设置新私钥
  return encryptor.decrypt(txt); // 对数据进行解密
}
